//
//  LDMyResumeBaseVoiceBtn.swift
//  DingDongZP
//
//  Created by LeMac on 16/12/28.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class LDMyResumeBaseVoiceBtn: UIView {
    
    var voiceImg:UIImageView?
    var voiceBtn:baseVoiceButton?
    dynamic var voiceLength:String?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
        initKVO()
        
    }
    
    //
    func initKVO() {
        
        //更新长度
        RACObserve(self, "voiceLength").subscribeNext { [weak self] (obj) in
            
            if obj != nil { self?.updataView() }
        }
        
    }
    
    func updataView() {
        
        voiceBtn?.snp_updateConstraints(closure: { (make) in
            
            make.width.equalTo(120)
        })
    }
    
    //
    func setupView() {
       
        voiceImg = UIImageView.init(image:UIImage(named: "话筒"))
        voiceBtn = baseVoiceButton()
        
        addSubview(voiceImg!)
        addSubview(voiceBtn!)
        
        voiceImg?.snp_makeConstraints(closure: { (make) in
            
            make.left.equalTo(0)
            make.centerY.equalTo(self)
            make.height.width.equalTo(24)
        })
        
        voiceBtn?.snp_makeConstraints(closure: { (make) in
            
            make.centerY.equalTo(voiceImg!)
            make.left.equalTo(voiceImg!.snp_right).offset(LDMargin_V*3)
            make.height.equalTo(28)
            make.width.equalTo(120)
        })

    }
    
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


}
